#include "terminalconsole.h"
#include "ui_terminalconsole.h"

TerminalConsole::TerminalConsole(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::TerminalConsole)
{
    ui->setupUi(this);
    //去窗口边框
    setWindowFlags(Qt::FramelessWindowHint | windowFlags());
    /* 插入音乐图标*/
    QPixmap pixmap_music;
    if(false==pixmap_music.load("g:/QtProjectImages/music.jpg"))
    {
        qDebug()<<"图片加载失败"<<endl;

    }
    //插入图片
    ui->label->setPixmap(pixmap_music);
    //缩放图片 适应边框
    ui->label->setScaledContents(true);

    /* 插入天气图标*/
    QPixmap pixmap_weather;
    if(false==pixmap_weather.load("g:/QtProjectImages/weather.jpg"))
    {
        qDebug()<<"图片加载失败"<<endl;

    }
    //插入图片
    ui->label_2->setPixmap(pixmap_weather);
    //缩放图片 适应边框
    ui->label_2->setScaledContents(true);

    /* 插入智能家居图标*/
    QPixmap pixmap_home;
    if(false==pixmap_home.load("g:/QtProjectImages/home.jpg"))
    {
        qDebug()<<"图片加载失败"<<endl;

    }
    //插入图片
    ui->label_3->setPixmap(pixmap_home);
    //缩放图片 适应边框
    ui->label_3->setScaledContents(true);

}

TerminalConsole::~TerminalConsole()
{
    delete ui;
}

void TerminalConsole::mouseMoveEvent(QMouseEvent *e)
{
    if (e->buttons() & Qt::LeftButton) {
               this->move(this->x() + e->globalX() - p.x(), this->y() + e->globalY() - p.y());
               p = e->globalPos();
           }
}

void TerminalConsole::mousePressEvent(QMouseEvent *e)
{
    if (e->button() == Qt::LeftButton) {
               p = e->globalPos();
    }
}


void TerminalConsole::on_toolButton_clicked()
{
    showMinimized();
}

void TerminalConsole::on_toolButton_2_clicked()
{
    close();
}

void TerminalConsole::on_pushButton_clicked()//music
{
    musicPage = new musicPlayer;
    musicPage->show();
    this->close();
}

void TerminalConsole::on_pushButton_2_clicked()//weather
{
    reportPage = new reportWeather;
    reportPage->show();
    this->close();
}

void TerminalConsole::on_pushButton_3_clicked()//home
{
    smartPage = new smartHome;
    smartPage->show();
    this->close();
}
